﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="SalesRefundCtrl.ascx.cs"
    Inherits="WebUI.Controls.SalesRefundCtrl" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<%@ Register Src="~/Controls/POSControls/InvoiceDetailsCtrl.ascx" TagName="InvoiceDetails"
    TagPrefix="uc" %>
<script type="text/javascript">
    function onEditProduct() {
        var id = getSelectedItemID<%=invoiceDetails.ClientID %>();
        if(id == null){
            alert("No item was selected!");
            return false;
        }
        var returnValue = window.showModalDialog('<%=GetInvoiceDetailsEditPageLink() %>' + '&mode=edit&id=' + id, '', 'dialogWidth=500px;dialogHeight=400px;resizable=no;help=no;unadorned=yes;');
        return returnValue > 0;
    }

    function onRemoveProduct() {
        return confirm("This action will delete all checked items. Do you want to continue?");
    }
    
    function onDiscountLostFocus(txt){        
        var qty = txt.value;
        if (qty == '') qty = 0;

        txt.value = qty;
    }
    
    function showPrintDlg(key) {
        var returnValue = window.showModalDialog(key, '', 'dialogWidth=800px;dialogHeight=600px;resizable=yes;help=no;unadorned=yes;');
    }

    function confirmRefund(){
        if(confirm("This action will revert the refunded invoice and create a new one. Do you want to continue?")){
            var btnHiddenSubmit = document.getElementById("<%= btnHiddenSubmit.ClientID %>");
            btnHiddenSubmit.click();
        }
    }
</script>
<asp:Panel ID="mainPanel" runat="server">
    <table width="100%">
        <tr>
            <td style="width: 50%; vertical-align: top">
                <asp:Panel ID="panelGeneral" runat="server" GroupingText="General Info">
                    <table width="100%">
                        <tr>
                            <td style="text-align: right; vertical-align: top; width: 80px">
                                <asp:Label ID="label1" runat="server" Text="Invoice#:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align: left; vertical-align: top">
                                <asp:TextBox ID="txtInvoiceNo" runat="server" Width="100px" ReadOnly="true"></asp:TextBox>
                            </td>
                            <td style="text-align: right; vertical-align: top">
                                <asp:Label ID="label3" runat="server" Text="Date:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align: left; vertical-align: top">
                                <asp:TextBox ID="txtDate" runat="server" Width="100px"></asp:TextBox>
                                <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate">
                                </cc1:CalendarExtender>
                                <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="Save" ID="RequiredFieldValidator1"
                                    runat="server" ControlToValidate="txtDate" class="requiredField" Text="required"
                                    ErrorMessage="required"></asp:RequiredFieldValidator>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right; vertical-align: top; width: 100px">
                                <asp:Label ID="label2" runat="server" Text="Invoice Type:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align: left; vertical-align: top">
                                <asp:DropDownList ID="ddlInvoiceType" runat="server">
                                </asp:DropDownList>
                                <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="Save" ID="reqInvoiceType"
                                    runat="server" ControlToValidate="ddlInvoiceType" class="requiredField" Text="required"
                                    ErrorMessage="required"></asp:RequiredFieldValidator>
                            </td>
                            <td style="text-align: right; vertical-align: top">
                                <asp:Label ID="label4" runat="server" Text="Staff:" class="labelMessage"></asp:Label>
                            </td>
                            <td style="text-align: left; vertical-align: top">
                                <asp:Label ID="lblStaff" runat="server" Text="" class="labelMessage"></asp:Label>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right; vertical-align: top">
                                <asp:Label ID="label5" runat="server" Text="Customer:" class="labelMessage"></asp:Label>
                            </td>
                            <td colspan="3" style="text-align: left; vertical-align: top">
                                <cc1:ComboBox ID="ddlCustomer" runat="server" AutoCompleteMode="Suggest" AutoPostBack="true"
                                    CssClass="WindowsStyle" DropDownStyle="Simple" AppendDataBoundItems="true" OnSelectedIndexChanged="ddlCustomer_OnSelectedIndexChanged"
                                    OnItemInserted="ddlCustomer_OnItemInserted" Width="200px">
                                </cc1:ComboBox>
                                <asp:Label ID="lblCustPrice" runat="server" Font-Size="16px" Font-Bold="true" CssClass="lblClass"></asp:Label>
                                <br />
                                <asp:Literal ID="lblCustInfo" runat="server"></asp:Literal>
                            </td>
                        </tr>
                        <tr>
                            <td style="text-align: right; vertical-align: top; padding-top:8px;">
                                <asp:Label ID="label11" runat="server" Text="Voucher:" class="labelMessage"></asp:Label>
                            </td>
                            <td colspan="3" style="text-align: left; vertical-align: top; padding-top:8px;">
                                <asp:TextBox ID="txtVoucherCode" runat="server" OnTextChanged="txtVoucherCode_OnTextChanged" AutoPostBack="true"></asp:TextBox>
                                <asp:Label ID="lblVoucher" runat="server" class="labelMessage" Font-Bold="true" ></asp:Label>
                                <asp:Panel ID="panelVoucher" runat="server">
                                    
                                </asp:Panel>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
            <td style="vertical-align: top">
                <asp:Panel ID="panelPayment" runat="server" GroupingText="Payment">
                    <table width="100%">
                        <tr>
                            <td>
                                <table width="100%">
                                    <tr>
                                        <td style="text-align: right; vertical-align: top; width: 100px">
                                            <asp:Label ID="label6" runat="server" Text="Total Amt:" class="labelMessage"></asp:Label>
                                        </td>
                                        <td style="text-align: left; vertical-align: top;">
                                            <asp:Label ID="lblTotalAmt" runat="server" Text="" class="labelMessage"></asp:Label>
                                            <asp:TextBox ReadOnly="true" Width="100px" ID="txtTotalAmt" runat="server" Text=""></asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right; vertical-align: top">
                                            <asp:Label ID="label8" runat="server" Text="Method:" class="labelMessage"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:DropDownList ID="ddlPaymentMethod" runat="server">
                                            </asp:DropDownList>
                                            <asp:RequiredFieldValidator Display="Dynamic" ValidationGroup="Save" ID="RequiredFieldValidator2"
                                                runat="server" ControlToValidate="ddlPaymentMethod" class="requiredField" Text="required"
                                                ErrorMessage="required"></asp:RequiredFieldValidator>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="text-align: right; vertical-align: top">
                                            <asp:Label ID="label10" runat="server" Text="Paid Amt:" class="labelMessage"></asp:Label>
                                        </td>
                                        <td>
                                            <asp:TextBox runat="server" ID="txtPayAmt" Width="100px"></asp:TextBox>
                                            <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" TargetControlID="txtPayAmt"
                                                FilterType="Numbers,Custom" ValidChars="." runat="server">
                                            </cc1:FilteredTextBoxExtender>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td style='vertical-align: top'>
                                <asp:Label ID="Label9" runat="server" Text="Note:" class="labelMessage"></asp:Label><br />
                                <asp:TextBox Width="200px" TextMode="MultiLine" Rows="4" runat="server" ID="txtNote"></asp:TextBox>
                            </td>
                        </tr>
                    </table>
                </asp:Panel>
            </td>
        </tr>
        <tr>
            <td colspan="2" align="left">
                <div>
                    <table width="100%" class="toolbar">
                        <tr>
                            <td style='vertical-align: middle'>
                                <asp:LinkButton class="tbbutton" ID="btnEditProd" runat="server" OnClientClick=" return onEditProduct();"
                                    OnClick="btnEditProd_Click">
                                    <asp:Image ID="image2" runat="server" ImageUrl="~/Images/Edit.gif" /><asp:Label ID="label12"
                                        runat="server" Text="Edit"></asp:Label>
                                </asp:LinkButton>
                                <asp:LinkButton class="tbbutton" ID="btnDeleteProd" runat="server" OnClientClick="return onRemoveProduct();"
                                    OnClick="btnRemoveProd_Click">
                                    <asp:Image ID="image3" runat="server" ImageUrl="~/Images/Delete.gif" /><asp:Label
                                        ID="label13" runat="server" Text="Delete"></asp:Label>
                                </asp:LinkButton>
                                <asp:Image ID="image1" runat="server" ImageUrl="~/Images/tbSep.png" />
                                <asp:LinkButton class="tbbutton" ID="btnDiscountAll" runat="server" OnClick="btnDiscountAll_OnClick">
                                    <asp:Image ID="image4" runat="server" ImageUrl="~/Images/trans.png" /><asp:Label
                                        ID="label7" runat="server" Text="Discount All(%)"></asp:Label>
                                </asp:LinkButton>
                                <asp:TextBox OnTextChanged="btnDiscountAll_OnClick" AutoPostBack="true" ID="txtDiscountAll"
                                    runat="server" onblur="onDiscountLostFocus(this);"></asp:TextBox>
                                <cc1:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" FilterType="Numbers" TargetControlID="txtDiscountAll"
                                    runat="server">
                                </cc1:FilteredTextBoxExtender>
                            </td>
                        </tr>
                    </table>
                    <uc:InvoiceDetails Width="100%" ID="invoiceDetails" runat="server" AllowSelecting="true"
                        AllowSorting="true" AllowPaging="false" />
                </div>
                <div style="height: 10px">
                    &nbsp;</div>
                <div style="text-align: center">
                    &nbsp;
                    <div style="float: right">
                        <asp:CheckBox ID="chkAutoPrint" runat="server" Text="Auto print after Submit" Checked="true" />
                    </div>
                    <%--                        <asp:Button ID="btnNewInvoice" runat="server" Text="New Invoice" OnClick="btnNewInvoice_OnClick" />--%>
                    <asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="confirmRefund(); return false;" />
                    <asp:Button ID="btnHiddenSubmit" ValidationGroup="Save" runat="server" Text="Submit" OnClick="btnSubmit_OnClick" style="display:none" />
                    <asp:Button ID="btnPrint" runat="server" Text="Print" OnClick="btnPrint_OnClick" />
                    <asp:HiddenField ID='hidNewInvoiceID' runat="server" />
                </div>
            </td>
        </tr>
    </table>
</asp:Panel>
